<template>
  <div class="topnav">
    <div class="logo">
      <router-link to="/">logo</router-link>
    </div>
    <ul class="menu">
      <li>菜单-2</li>
      <li>菜单-1</li>
    </ul>
    <div class="toggleAside" @click="toggleMenu"></div>
  </div>
</template>

<script lang="ts">
import { inject, Ref } from "vue"
export default {
  name: "Topnav",
  setup() {
    const asideVisible = inject<Ref<boolean>>("asideVisible")
    const toggleMenu = () => {
      asideVisible.value = !asideVisible.value
    }

    return { toggleMenu }
  },
}
</script>

<style lang="scss" scoped>
.topnav {
  background: pink;
  display: flex;
  padding: 16px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  justify-content: center;
  align-items: center;
  > .logo {
    max-width: 6em;
    margin-right: auto;
  }
  > .menu {
    display: flex;
    white-space: nowrap;
    flex-wrap: nowrap;
    margin-right: 1em;;
    > li {
      margin: 0 1em;
    }
  }
  > .toggleAside {
    width: 24px;
    height: 24px;
    background: red;
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
  }
  @media (max-width: 500px) {
    > .menu {
      display: none;
    }
    > .logo {
      margin: 0 auto;
    }
    > .toggleAside {
      display: inline-block;
    }
  }
}
</style>
